#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

#include <plugin.h>

#include <ui_form.h>

void PluginClose()
{
    SendCommand( PCMD_NormalUnit, 0, UNIT_InfoBox );		// release org infobox.
    SendCommand( PCMD_NormalUnit, 0, UNIT_DirectBar );		// release simple svclist.

    WiTask_Sleep(200);

    FontClose();
    WiFront_Term();
}

int PluginMain( int argc, char *argv[] )
{
    ui_form form;

    int key, mainState = STATE_None;
    int sharacamd_pid = 0;
    dword evt[4] = {0,};

    WiFront_Init();
    FontInit( "sfam.ttf" );

    SendCommand( PCMD_NormalUnit, 1, UNIT_InfoBox );		// block org infobox.
    SendCommand( PCMD_NormalUnit, 1, UNIT_DirectBar );		// block simple svclist.

    mainState = GetState(STATEIDX_Main);

    if( mainState == STATE_Normal ) {	// live mode
        SendCommand( PCMD_NotifyMsg, APPLMSG_Destroy );
    }

    sharacamd_pid = getpid();

    while( 1 )
    {
        if( WiQueue_Receive(WiMainQ, (u_int8 *)evt, 16, -1) != 0 ) continue;

        if( (evt[0] & MSG_BASE_MASK) == MSG_BASE_REMOCON ) {

            key = evt[1] & MSG_MASK_KEY_CODE;

        }
    }
}
